package com.cskaoyan.javase.practice.stage3;

import java.nio.file.NotLinkException;
import java.util.Scanner;

/**
 * @program: little-practice
 * @description: a String list store student info.
 * @author: Keyu Li
 * @create: 2021-08-28 20:08
 **/

public class StudentManageSystem {
    public static void main(String[] args) {
        // create a student list that could contain 10 sstudents
        Student[] stu = new Student[10];
        //for test only
        tempAddStuList(stu);
        final Scanner sc = new Scanner(System.in);
        int menuNum;

        while (true) {
            printMenu();
            menuNum = Integer.parseInt(sc.nextLine());

            if (menuNum == 1) {
                StudentListTool.showStudentList(stu);
            } else if (menuNum == 2) {
                StudentListTool.addStudentInfo(stu);
            } else if (menuNum == 3) {
                StudentListTool.deleteStudentInfo(stu);
            } else if (menuNum == 4) {
                StudentListTool.updateStudentInfo(stu);
            } else if (menuNum == 5) {
                StudentListTool.searchStudentInfo(stu);
            } else if (menuNum == 6) {
                System.out.println("确认退出吗（1/2）：");
                if (Integer.parseInt(sc.nextLine()) == 1)
                    return;
            } else {
                System.out.println("input illegal!");
            }
        }
    }

    private static void tempAddStuList(Student[] stu) {
        stu[0] = new Student(1,"bill","male",16,4,10045);
        stu[1] = new Student(2,"jobs","female",26,12,213862);
        stu[2] = new Student(3,"jordan","male",6,1,12179);
        StudentListTool.stuIdCount = 4;
    }


    public static void printMenu() {
        System.out.println();
        System.out.println("-------------王道Java学生管理系统---------");
        System.out.println();
        System.out.println("              1.学 生 列 表");
        System.out.println("              2.增 加 学 生");
        System.out.println("              3.删 除 学 生");
        System.out.println("              4.修 改 学 生");
        System.out.println("              5.查 询 学 生");
        System.out.println("              6.退 出 系 统");
        System.out.println("请选择功能（1-6）：");
    }
}
